package com.eos.control.action.activity;

import com.eos.business.service.SysActivityBusinessService;
import com.eos.common.tool.ConstantTool;
import com.eos.common.tool.ObjectUtils;
import com.eos.control.action.base.AbstractBaseAction;
import com.eos.orm.mybatis.model.SysActivtySon;
import com.eos.orm.mybatis.model.SysUser;
import com.hf.utils.StringUtil;

public class UpdateSonActivityAction extends AbstractBaseAction {
	private static final long serialVersionUID = -1254847586774612344L;
	private String sonActivityId; //格式:子活动ID_父活动ID
	private String activtySonName;
	private String activtySonDesc;

	public void setSonActivityId(String sonActivityId) {
		this.sonActivityId = sonActivityId;
	}

	public void setActivtySonName(String activtySonName) {
		this.activtySonName = activtySonName;
	}

	public void setActivtySonDesc(String activtySonDesc) {
		this.activtySonDesc = activtySonDesc;
	}

	@Override
	public String execute() {
		try {
			if (StringUtil.isEmpty(sonActivityId)) {
				statusCode = "300";
				message = "参数错误, 修改子活动信息失败!";
			} else {
				int sid = Integer.parseInt(sonActivityId.split("_")[0]);
				SysUser user = (SysUser) getSession().getAttribute("SysUser");
				SysActivityBusinessService sabs = new SysActivityBusinessService();
				SysActivtySon sas = new SysActivtySon();
				sas.setId(sid);
				sas.setActivtySonName(activtySonName);
				sas.setActivtySonDesc(activtySonDesc);
				sas.setDealFlag(ConstantTool.DEAL_FALG_OK);
				sas.setUpdateUserId(user.getId()+"");
				sas.setModifyTime(ObjectUtils.formatDate(null, "yyyy-MM-dd HH:mm:ss"));
				String exeStatus = sabs.updateSonActivityPKSelective(sas);
				if ("SUCCESS".equals(exeStatus)) {
					statusCode = "200";
					message = "修改子活动信息成功!";
				} else {
					statusCode = "300";
					message = "系统繁忙, 修改子活动信息失败!";
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			statusCode = "300";
			message = "系统异常, 修改子活动信息失败!";
		}
		return SUCCESS;
	}

}
